﻿using System.Web.Routing;
using Inovout.Web.Mvc;
using Inovout.YunYao.Models;
using Inovout.YunYao.Services;
using System.Web.Mvc;
using System.Collections.Generic;

namespace Inovout.YunYao.Solutions.Web.Controllers
{
    public class MonitoringElementController<T> : RepositoryController<T>, IMonitoringElementController where T : IMonitoringElement
    {
        protected virtual IMonitoringElementService<T> MonitoringElementService
        {
            get { return (IMonitoringElementService<T>)base.RepositoryService; }
        }
        public Solution Solution
        {
            get;
            private set;
        }

        protected override void Initialize(RequestContext requestContext)
        {
            base.Initialize(requestContext);

            RouteData routeData = requestContext.RouteData;
            ISolutionService solutionService = ComponentRegistry.Resolve<ISolutionService>();
            Solution = solutionService.FindByCode(int.Parse(routeData.Values["solution"].ToString()));
            ViewBag.Solution = Solution;
            ViewBag.Navigations = new List<Navigation> { 
                new Navigation{Text="特性",Url= Url.Action("List","Feature")},
                new Navigation{Text="设备",Url=Url.Action("List","Equipment")},
                new Navigation{Text="设施",Url=Url.Action("List","MonitoringObject")},
                new Navigation{Text="测点",Url=Url.Action("List","MonitoringNode")}
            };
        }

        public override ActionResult Index()
        {
            return RedirectToAction("List", "Feature");
        }
    }
}